/* GUI CONVERTED from reoptr1c.p (converter v1.75) Sat Aug 12 23:07:31 2000 */
/* reoptr1c.p - NON-MILESTONE OPERATION POSTING (from sfopclse)         */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/*F0PN*/ /*V8:ConvertMode=Maintenance                                   */
/*V8:RunMode=Character,Windows                                          */
/* REVISION: 7.3      LAST MODIFIED: 11/05/92   BY: emb *G689*          */
/* REVISION: 7.4      LAST MODIFIED: 01/12/94   BY: qzl *H276*/
/* Oracle changes (share-locks)    09/12/94           BY: rwl *FR25*    */
/* REVISION: 7.4      LAST MODIFIED: 11/28/95   BY: jym *F0WD*          */
/* REVISION: 8.6      LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan   */
/* REVISION: 9.1      LAST MODIFIED: 10/01/99   BY: *N014* Murali Ayyagari */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb             */

     {mfdeclre.i}

     define input parameter complot like op_wo_lot.
     define input parameter compop like op_wo_op.
     define input parameter transtype as character.
     define input parameter wo_recid as recid.
     define input parameter eff_date like glt_effdate.
     define input parameter shift like op_shift.
     define input parameter qty_comp like wr_qty_comp.

     define new shared variable opgltype like opgl_type.
     define new shared variable op_recno as recid.
     define new shared variable wr_recno as recid.
     define new shared variable wc_recno as recid.
     define new shared variable pay_rate like wc_lbr_rate.

     define new shared variable ref like glt_ref.
     define new shared variable sf_cr_acct like dpt_lbr_acct.
     define new shared variable sf_dr_acct like dpt_lbr_acct.
/*N014*/ define new shared variable sf_cr_sub like dpt_lbr_sub.
/*N014*/ define new shared variable sf_dr_sub like dpt_lbr_sub.
     define new shared variable sf_cr_cc like dpt_lbr_cc.
     define new shared variable sf_dr_cc like dpt_lbr_cc.
     define new shared variable sf_gl_amt like glt_amt.

     define            variable routing like wo_routing.
/*H276*/ define     shared variable last_date like op_date.
/*F0WD*/ define     shared variable prline like rps_line no-undo.

     find wo_mstr no-lock where recid(wo_mstr) = wo_recid.
     routing = wo_routing.
     if routing = "" then routing = wo_part.

/*FR25*/ for each wr_route exclusive-lock where
     wr_lot = complot and wr_op < compop
     by wr_lot descending by wr_op descending:
/*GUI*/ if global-beam-me-up then undo, leave.


        if wr_milestone then leave.

        /*SKIP SUBCONTRACT OPERATIONS*/
        find ro_det where ro_routing = routing
        and ro_op = wr_op and
/*H276*/    (ro_start = ? or ro_start <= last_date) and
/*H276*/    (ro_end = ? or ro_end >= last_date) no-lock no-error.

        if available ro_det and ro_sub_cost <> 0 then next.

        if wr_status = "C" then next.

        find wc_mstr where wc_wkctr = wr_wkctr and wc_mch = wr_mch
        no-lock no-error.
        if not available wc_mstr then undo, retry.

        wr_act_run = wr_act_run + (qty_comp * wr_run).

        create op_hist.

        {mfnoptr.i}

        assign op_wo_nbr = wr_nbr
           op_wo_lot = wr_lot
            op_wo_op = wr_op
             op_part = wr_part
             op_site = wo_site
/*F0WD*/             op_line = prline
        op_milestone = wr_milestone
          op_project = wo_project
        op_tran_date = today
             op_type = transtype
            op_wkctr = wr_wkctr
              op_mch = wr_mch
         op_qty_comp = qty_comp
             op_date = eff_date
            op_shift = shift
          op_std_run = wr_run
          op_act_run = wr_run * qty_comp
             op_dept = wc_dept.

        if wr_act_setup = 0 then do:
           /* If no setup has been reported,
          post the entire setup at standard */
           op_std_setup = wr_setup.
           op_act_setup = wr_setup.
           wr_act_setup = wr_setup.
        end.
        else do:
           /* If any setup has been reported,
          post the remaining setup as variance */
           op_std_setup = max(0,wr_setup - wr_act_setup).
           op_act_setup = 0.
        end.

        op_recno = recid(op_hist).
        wr_recno = recid(wr_route).
        wc_recno = recid(wc_mstr).
        pay_rate = wc_lbr_rate.

        {gprun.i ""sfoptrc1.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


        /* NOTE: pay_rate = wc_lbr_rate, So no rate variances are
             created, and actrun = stdrun, So no 'run' usage
             variances are created. */

        assign
           wr_qty_wip = 0
          wr_qty_comp = wr_qty_comp + qty_comp.
     end.
/*GUI*/ if global-beam-me-up then undo, leave.

